import { Component, OnDestroy, OnInit } from '@angular/core';
import { BaseFieldComponent } from '..';
// import * as ClassicEditor from '@ckeditor/ckeditor5-build-classic';
// import { ChangeEvent } from '@ckeditor/ckeditor5-angular';
// import * as InlineEditor from '@ckeditor/ckeditor5-build-inline';

@Component({
  selector: 'zepride-text-area',
  templateUrl: './text-area.component.html',
  styleUrls: ['./text-area.component.less', '../field.common.less']
})
export class TextAreaComponent extends BaseFieldComponent implements OnInit, OnDestroy {
  // Editor = InlineEditor; // ClassicEditor;
  txtContent = '';

  async ngOnInit() {
    if (this.componentData.bindField) {
      this.txtContent = this.dataModel[this.componentData.bindField];
    }
  }

  // public onChange({ editor }: ChangeEvent) {
  //   this.setBindData(this.txtContent);
  // }

  ngOnDestroy() {
    if (this.modelChange$) {
      this.modelChange$.unsubscribe();
    }
  }

  public onReady(editor) {
    editor.ui.getEditableElement().parentElement.insertBefore(
      // editor.ui.view.toolbar.element, common\engines\components\fields\place-select
      null,
      editor.ui.getEditableElement()
    );
  }

}
